package com.concretepage.controller;

import ch.qos.logback.classic.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.Authentication;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;

import com.concretepage.service.IUserService;
import org.springframework.web.bind.annotation.RequestMethod;

@Controller
@RequestMapping("/user")
public class UserController {

	@Autowired
	private  IUserService service;



	@RequestMapping(value="/home")
	public String home(ModelMap model, Authentication authentication) {
		authentication.getPrincipal();
		model.addAttribute("user", service.getDataByUserName(authentication.getName()));
 		return "user/user-info";
 	}


 	@RequestMapping("/register")
 	public String register(){
		return "user/register";
	}


	@RequestMapping(value = "/appregister",method = RequestMethod.POST)
	public String appregister(String username,String password){
		System.out.println("username:"+username+",pass:"+password);
 		return "customLogin";
	}


	@RequestMapping(value="/error")
	public String error() {
 		return "/secure/access-denied";
 	}
}	